#include "borderlayer.h"
#include <limits.h>
using namespace std;

BorderLayer::BorderLayer(){
    layerBorder = NULL;
}

void BorderLayer::setLayer(Layer* layer){
    layerBorder = layer;
    if(layer != NULL){
        refreshPos();
    }
}

void BorderLayer::refreshPos(){
    setPos(layerBorder->x(), layerBorder->y());
    width = layerBorder->getWidth();
    height = layerBorder->getHeight();
}

void BorderLayer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
    QPen penWrite(Qt::white);

    QVector<qreal> dashesWrite;
    dashesWrite << 4 << 10;
    penWrite.setDashPattern(dashesWrite);
    penWrite.setDashOffset (0);
    painter->setPen(penWrite);

    painter->drawRect(0, 0, width, height);

    QPen pen(Qt::darkCyan);
    pen.setStyle(Qt::DashLine);
    pen.setDashOffset (2);
    QVector<qreal> dashes;

    dashes << 2 << 12;
    pen.setDashPattern(dashes);
    painter->setPen(pen);

    painter->drawRect(0, 0, width, height);
}

QRectF BorderLayer::boundingRect() const{
    return QRectF(-INT_MAX / 2, -INT_MAX / 2, INT_MAX, INT_MAX);
}
